package gui;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.JToolBar;

public class PanelTest {
	
	private JFrame frame;
	private JTable leftTable;
	private JTable rightTable;

	/**
	 * Create the panelLeft.
	 */
	public PanelTest() {
		
		frame = new JFrame();
		frame.setBounds(100, 100, 889, 391);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(new GridLayout(1, 2, 0, 0));

		//LEFT PANEL
		JPanel panelLeft = new JPanel();
		frame.getContentPane().add(panelLeft);
		GridBagLayout gbl_panel = new GridBagLayout();
		gbl_panel.columnWidths = new int[]{395};
		gbl_panel.rowHeights = new int[]{20, 27, 321, 0};
		gbl_panel.columnWeights = new double[]{1.0};
		gbl_panel.rowWeights = new double[]{0.0, 0.0, 1.0, Double.MIN_VALUE};
		panelLeft.setLayout(gbl_panel);
		
		JPanel btnPanelLeft = new JPanel();
		GridBagConstraints gbc_btnPanelLeft = new GridBagConstraints();
		gbc_btnPanelLeft.fill = GridBagConstraints.BOTH;
		gbc_btnPanelLeft.insets = new Insets(0, 0, 5, 5);
		gbc_btnPanelLeft.gridx = 0;
		gbc_btnPanelLeft.gridy = 0;
		panelLeft.add(btnPanelLeft, gbc_btnPanelLeft);
		btnPanelLeft.setLayout(new GridLayout(0, 4, 0, 0));
		
		JToolBar toolBar = new JToolBar();
		btnPanelLeft.add(toolBar);
		
		JButton btnLeft = new JButton("bl");
		toolBar.add(btnLeft);
		
		JButton btnLeft1 = new JButton("bl1");
		toolBar.add(btnLeft1);
		
		JPanel addrPanelLeft = new JPanel();
		GridBagConstraints gbc_addrPanelLeft = new GridBagConstraints();
		gbc_addrPanelLeft.fill = GridBagConstraints.BOTH;
		gbc_addrPanelLeft.insets = new Insets(0, 0, 5, 5);
		gbc_addrPanelLeft.gridx = 0;
		gbc_addrPanelLeft.gridy = 1;
		panelLeft.add(addrPanelLeft, gbc_addrPanelLeft);
		GridBagLayout gbl_addrPanelLeft = new GridBagLayout();
		gbl_addrPanelLeft.columnWidths = new int[]{390, 0, 0};
		gbl_addrPanelLeft.rowHeights = new int[]{22, 0};
		gbl_addrPanelLeft.columnWeights = new double[]{1.0, 0.0, Double.MIN_VALUE};
		gbl_addrPanelLeft.rowWeights = new double[]{0.0, Double.MIN_VALUE};
		addrPanelLeft.setLayout(gbl_addrPanelLeft);
		
		JTextField AddrTextFLeft = new JTextField();
		GridBagConstraints gbc_AddrTextFLeft = new GridBagConstraints();
		gbc_AddrTextFLeft.insets = new Insets(0, 0, 0, 5);
		gbc_AddrTextFLeft.fill = GridBagConstraints.BOTH;
		gbc_AddrTextFLeft.gridx = 0;
		gbc_AddrTextFLeft.gridy = 0;
		addrPanelLeft.add(AddrTextFLeft, gbc_AddrTextFLeft);
		
		JButton btnGoLeft = new JButton("I");
		GridBagConstraints gbc_btnGoLeft = new GridBagConstraints();
		gbc_btnGoLeft.gridx = 1;
		gbc_btnGoLeft.gridy = 0;
		addrPanelLeft.add(btnGoLeft, gbc_btnGoLeft);
		
		JScrollPane scrollPaneLeft = new JScrollPane();
		GridBagConstraints gbc_scrollPaneLeft = new GridBagConstraints();
		gbc_scrollPaneLeft.fill = GridBagConstraints.BOTH;
		gbc_scrollPaneLeft.insets = new Insets(0, 0, 0, 5);
		gbc_scrollPaneLeft.gridx = 0;
		gbc_scrollPaneLeft.gridy = 2;
		panelLeft.add(scrollPaneLeft, gbc_scrollPaneLeft);
		
		leftTable = new JTable(new FilesTableModel(null, new String[]{"Nazwa", "Rozszerzenie", "Wielkość", "Data mod.", "Atrybuty"}));
		scrollPaneLeft.setViewportView(leftTable);
		
		//////////////////////////RIGHT TABLE////////////////////////////////////////////////
		////////////////////////////////////////////////////////////////////////////////////
		JPanel panelRight = new JPanel();
		frame.getContentPane().add(panelLeft);
		GridBagLayout gbl_panel1 = new GridBagLayout();
		gbl_panel1.columnWidths = new int[]{395};
		gbl_panel1.rowHeights = new int[]{20, 27, 321, 0};
		gbl_panel1.columnWeights = new double[]{1.0};
		gbl_panel1.rowWeights = new double[]{0.0, 0.0, 1.0, Double.MIN_VALUE};
		panelRight.setLayout(gbl_panel1);
		
		JPanel btnPanelRight = new JPanel();
		GridBagConstraints gbc_btnPanelRight = new GridBagConstraints();
		gbc_btnPanelRight.fill = GridBagConstraints.BOTH;
		gbc_btnPanelRight.insets = new Insets(0, 0, 5, 5);
		gbc_btnPanelRight.gridx = 0;
		gbc_btnPanelRight.gridy = 0;
		panelRight.add(btnPanelRight, gbc_btnPanelRight);
		btnPanelRight.setLayout(new GridLayout(0, 4, 0, 0));
		
		JToolBar toolBar_1 = new JToolBar();
		btnPanelRight.add(toolBar_1);
		
		JButton btnRight = new JButton("b");
		toolBar_1.add(btnRight);
		
		JButton btn1Right = new JButton("b1");
		toolBar_1.add(btn1Right);
		
		JPanel addrPanelRight = new JPanel();
		GridBagConstraints gbc_addrPanelRight = new GridBagConstraints();
		gbc_addrPanelRight.fill = GridBagConstraints.BOTH;
		gbc_addrPanelRight.insets = new Insets(0, 0, 5, 5);
		gbc_addrPanelRight.gridx = 0;
		gbc_addrPanelRight.gridy = 1;
		panelRight.add(addrPanelRight, gbc_addrPanelRight);
		GridBagLayout gbl_addrPanelRight = new GridBagLayout();
		gbl_addrPanelRight.columnWidths = new int[]{390, 0, 0};
		gbl_addrPanelRight.rowHeights = new int[]{22, 0};
		gbl_addrPanelRight.columnWeights = new double[]{1.0, 0.0, Double.MIN_VALUE};
		gbl_addrPanelRight.rowWeights = new double[]{0.0, Double.MIN_VALUE};
		addrPanelRight.setLayout(gbl_addrPanelRight);
		
		JTextField AddrTextFRight = new JTextField();
		GridBagConstraints gbc_AddrTextFRight = new GridBagConstraints();
		gbc_AddrTextFRight.insets = new Insets(0, 0, 0, 5);
		gbc_AddrTextFRight.fill = GridBagConstraints.BOTH;
		gbc_AddrTextFRight.gridx = 0;
		gbc_AddrTextFRight.gridy = 0;
		addrPanelRight.add(AddrTextFRight, gbc_AddrTextFRight);
		
		JButton btnGoRight = new JButton("I");
		GridBagConstraints gbc_btnGoRight = new GridBagConstraints();
		gbc_btnGoRight.gridx = 1;
		gbc_btnGoRight.gridy = 0;
		addrPanelRight.add(btnGoRight, gbc_btnGoRight);
		
		JScrollPane scrollPaneRight = new JScrollPane();
		GridBagConstraints gbc_scrollPaneRight = new GridBagConstraints();
		gbc_scrollPaneRight.fill = GridBagConstraints.BOTH;
		gbc_scrollPaneRight.insets = new Insets(0, 0, 0, 5);
		gbc_scrollPaneRight.gridx = 0;
		gbc_scrollPaneRight.gridy = 2;
		panelRight.add(scrollPaneRight, gbc_scrollPaneRight);
		
		rightTable = new JTable(new FilesTableModel(null, new String[]{"Nazwa", "Rozszerzenie", "Wielkość", "Data mod.", "Atrybuty"}));
		scrollPaneRight.setViewportView(rightTable);
		
		JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panelLeft, panelRight);
		frame.getContentPane().add(splitPane);
		frame.setVisible(true);
		
		
		

	}
	
	public static void main(String[] args) {
		//PanelTest p = new PanelTest();
		try {
			System.out.println(Files.getPosixFilePermissions(FileSystems.getDefault().getPath("/java/black.png"), LinkOption.NOFOLLOW_LINKS));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
